using System;
using System.Collections.Generic;
using System.Text;

namespace TMSIM.Client.CM.Business
{
    public class MenuHelper
    {
        private System.Windows.Forms.ToolStripMenuItem topmenu;
        public System.Windows.Forms.ToolStripMenuItem TopMenu
        {
            get
            {
                return topmenu;
            }
            set
            {
                topmenu = value;
            }
        }

        private bool isDropDownOpened = false;

        public void InitMenu()
        {
            topmenu.MouseEnter += topmenu_MouseEnter;
            topmenu.DropDownOpened += topmenu_DropDownOpened;
            topmenu.DropDownClosed += topmenu_DropDownClosed;
            topmenu.MouseLeave += TopMenu_MouseLeave;
        }

        void topmenu_DropDownOpened(object sender, EventArgs e)
        {
            topmenu.ForeColor = System.Drawing.Color.Black;
            isDropDownOpened = true;
        }

        void topmenu_DropDownClosed(object sender, EventArgs e)
        {
            topmenu.ForeColor = System.Drawing.Color.White;
            isDropDownOpened = false;
        }

        void topmenu_MouseEnter(object sender, EventArgs e)
        {
            topmenu.ForeColor = System.Drawing.Color.Black;
        }

        void TopMenu_MouseLeave(object sender, EventArgs e)
        {
            if (!isDropDownOpened)topmenu.ForeColor = System.Drawing.Color.White;
        }

    }
}
